<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        *{
            margin-top: 20px;
        }
        .demo1{
            height: 50px;
            background-color: aqua;
        }
        .box1{
           padding: 5px;
            background-color: antiquewhite;
        }
        .box2{
            padding: 5px;
            background-color: aquamarine;
        }
    </style>
</head>
<body>
    <div id="root">
        <h2>欢迎来到{{name}}学习</h2>
        <!--阻止默认事件-->
        <a href="https://www.baidu.com" @click.prevent="showInfo">点击</a>
        <!--阻止事件冒泡-->
        <div class="demo1" @click="showInfo">
            <button @click.stop="showInfo">点击</button>
        </div>
        <!--事件只触发一次-->
        <button @click.once="showInfo">点击</button>
        <!--使用事件的捕获模式-->
        <div class="box1" @click.capture="showMsg(1)">
            div1
            <div class="box2" @click="showMsg(2)">
                div2
            </div>
        </div>
        <!--只有event.target是当前操作的元素时才触发事件-->
        <div class="demo1" @click.self="showInfo">
            <button @click="showInfo">点击</button>
        </div>
        <ul>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
            <li></li>
        </ul>
    </div>
    <script src="../js/vue.js"></script>
    <script>
            Vue.config.productionTip=false//阻止vue启动时产生提示
            new Vue({
                 el: "#root",
                 data:{
                      name:'cljh',

                    },
                 methods:{
                     showInfo(e){

                         alert('同学你好')
                         console.log(e.target)
                     },
                     showMsg(msg){
                         console.log(msg)

                     }
                 }
             })
    </script>
</body>
</html>